package com.ptswitch.material.components;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.corelib.base.AbstractConditional;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hxzon.util.OgnlUtil;

import com.ptswitch.material.model.common.Uzer;

public class Logined extends AbstractConditional {
    @Inject
    private ComponentResources componentResources;

    @Override
    protected boolean test() {
        Uzer visitor = (Uzer) OgnlUtil.getValue(componentResources.getPage(), "visitor");
        if (visitor == null) {
            return false;
        }
        return !Uzer.Username_Guess.equals(visitor.getUsername());
    }

}
